﻿<!doctype html>
<html>
	<!-- InstanceBegin template="/Templates/template1.dwt" codeOutsideHTMLIsLocked="false" -->
	<head>
		<meta charset="utf-8">
		<!-- InstanceBeginEditable name="doctitle" -->
		<title>优惠券使用明细</title>
		<!-- InstanceEndEditable -->
		<script type="text/javascript" src="../js/common.js"></script>
		<script type="text/javascript" src="../js/qmsk-1.2.js"></script>
		<link href="../css/Pager.css" type="text/css" rel="stylesheet" />
		<script type="text/javascript" src="../js/jquery.pager.js"></script>
		<script type="text/javascript" src="../js/gbRst.js"></script>
		<script type="text/javascript" src="../js/utils.js"></script>
		<script type="text/javascript" src="../js/shop.js"></script>
		<script type="text/javascript" src="../js/checkLogin.js"></script>
		<script type="text/javascript" src="../js/shopSelecter.js"></script>
		<script type="text/javascript" src="../js/find.js"></script>
		<link href="../css/style.css" type="text/css" rel="stylesheet" />
		<!-- InstanceBeginEditable name="head" -->
		<!-- InstanceEndEditable -->
		<script type="text/javascript" >
			$(function() {
				$("#shopIsChoosed").click(function() {
					if ($("#shopIsChoosed").is(":checked")) {
						$("#shopName").attr("disabled", false);
						$("#research").attr("disabled", false);

					} else {
						$("#shopName").attr("disabled", true);

					}
				});
			});
			function InitTable(pageIndex) {
				var code = $("#code").val().replace(/\s/gi, '');
				var dtBegin = $("#dtBegin").val();
				var dtEnd = $("#dtEnd").val();
				var shopId = "";
				var param = "&code=" + code + "&dtBegin=" + dtBegin + "&dtEnd=" + dtEnd;
				if ($("#shopIsChoosed").is(":checked")) {
					shopId = $("#shopName").val();
					if (shopId != "" && shopId != null) {
						param += "&shopId=" + shopId;
					}
				}

				$.ajax({
					type : "get",
					async : false,
					data : param,
					datatype : "json",
					url : "../memberConpCsm/find/memberCouponCsm/" + pageIndex + "/10",
					success : function(data) {
						var rst = JSON.parse(data);

						if (rst.state == 0) {
							$("#memberList tbody tr").remove();
							var obj = DealAndShowMsg(data, false, false);
							initTable(rst);
							if (rst.result.len > 0) {
								var shu = rst.result.len;
								$("#NoResult").hide();
								pagecount = Math.ceil(shu / 10);
							} else {
								$("#NoResult").show();
								pagecount = 0;

							}
							$("#sup").html("共" + rst.result.len + "条");
							$("#pager").pager({
								pagenumber : ++pageIndex,
								pagecount : pagecount,
								buttonClickCallback : PageClick
							});

						} else if (rst.state == 1) {
							art.dialog({
								fixed : true,
								lock : true,
								content : rst.msg,
								icon : 'error',
								ok : true
							});
						} else {
							checkStateShowErrorMsgAndDealResult(data);
						}

					}
				});
				$.ajax({
					type : "get",
					async : false,
					data : param,
					datatype : "json",
					url : "../memberConpCsm/find/faceValueSum",
					success : function(data) {
						var rst = JSON.parse(data);
						if (rst.state == 0) {
							$("#sum").html("总计：" + getHtmlString(getHeadIndexValue(0, rst, "sum")) + "元");
						} else if (rst.state == 1) {
							art.dialog({
								fixed : false,
								lock : true,
								content : rst.msg,
								icon : 'error',
								ok : true
							});
						}
					}
				});

			}

			PageClick = function(pageclickednumber) {
				$("#pager").pager({
					pagenumber : --pageclickednumber,
					pagecount : pagecount,
					buttonClickCallback : PageClick
				});
				$("#result").html("Clicked Page " + pageclickednumber);
				InitTable(pageclickednumber, shopId);
			};
			function search() {
				InitTable(0);
			}

			function initTable(json) {
				if (json != null && json.state == 0) {
					var params = new Array("id", "Date", "ShopName", "CouponNo", "memberCardNo", "CustomerName", "mp", "CouponCount", "FaceValue", "staName", "memo");
					// "PayCash", "PayPos", "PayDepstAmt", "PayCheck", "PayPersonCard", "PayIntAmtMny", "StaName", "PaidName"
					var response = new qmsk.Response(json);

					var printHandler = function(id) {
						return "<input onclick='print(" + id + ")' type='button' class='common_btn' value='打印'>";
					};
					qmsk.dataTable({
						tbodyId : 'consumeList',
						heads : ["Date", "ShopName", "CouponNo", "memberCardNo", "CustomerName", "mp", "CouponCount", "FaceValue", "staName", "memo", "id"],
						response : response,
						sup : ['clxx_simpleList_sup', '共 [index] 条'],
						handler : [[10, printHandler]]

					});

				}

			}

			function print(consumeId) {
				window.open("printCheckCoupon.html?consumeId=" + consumeId);
			}

			function downRescouse() {
				var code = $("#code").val().replace(/\s/gi, '');
				var dtBegin = $("#dtBegin").val();
				var dtEnd = $("#dtEnd").val();
				var shopId = "";
				var param = "&code=" + code + "&dtBegin=" + dtBegin + "&dtEnd=" + dtEnd;
				if ($("#shopIsChoosed").is(":checked")) {

					shopId = $("#shopName").val();

					if (shopId != "" && shopId != null) {
						param += "&shopId=" + shopId;
					}
				}
				param += "&downType=3"

				window.location.href = "../csvdown/down/csv/down?" + param

			}

		</script>
	</head>

	<body>
		<div id="yinying"></div>
		<div id="shopShow" class="hideDiv">
			<div style="float:right;margin-bottom:5px;width:20px;height:20px;line-height:20px;text-align:center;background-color:#eee;margin-bottom:5px;border:1px solid #ccc;" >
				<span style="cursor: pointer;font-size: 14px;" onclick="closeShopShow();" >X</span>
			</div>
			<div class="bottom_search">
				<div class="serWrapper">
					<input type="text" id="searchName" class="txt">
					<strong class="refresh" onclick="$('#searchName').val('')">清空</strong>
				</div>
				<input type="button" style="width:auto;margin-left:5px;" value="查询" onclick="search2()" class="common_btn">
			</div>
			<table   id="shopList" cellpadding="4" cellspacing="0" border="1" width="100%">
				<thead>
					<tr>
						<th>店面ID</th>
						<th>店面名称</th>
						<th>电话</th>
						<th>操作</th>
					</tr>
				</thead>
			</table>
			<div id="shopPager"></div>
		</div>
		<!-- InstanceBeginEditable name="EditRegion3" -->
		<script type="text/javascript" src="../js/doubleDate2.0.js"></script>
		<script type="text/javascript">
			$(function() {
				refreshInput($(".serWrapper"));
				$('.doubledate').kuiDate({
					className : 'doubledate',
					isDisabled : "1" // isDisabled为可选参数，“0”表示今日之前不可选，“1”标志今日之前可选
				});

			});
		</script>
		<div class="container" id="container">
			<div class="container_R fr">
				<div class="place">
					优惠券使用明细
				</div>
				<div class="member_search">
					<p>
						<span>
							<input type="checkbox" id="shopIsChoosed" style="width:auto;height:auto;border:none;">
							店面：</span>
						<select id="shopName" onclick="openShopListPanel(this)" style=";height:20px;" disabled="disabled"></select>
						<span>起始日期：</span>
						<input type="text" readonly class="doubledate ipticon"  id="dtBegin"/>
						<span>截止时间：</span>
						<input type="text" readonly class="doubledate ipticon" id="dtEnd"/>
					</p>
					<p>
						<span>优惠劵号：</span>
						<input type="text" id="code" class="absoluteTxt">
						<input type="button" value="查询" class="btn" onclick="search()">
					</p>
				</div>
				<table width="100%" class="member_list" cellpadding="0" cellspacing="1" border="0" id="memberList">
					<caption>
						<strong>优惠券使用明细列表 <span id="sup">共0条</span> </strong><a href="javascript:void(0)" onclick="downRescouse()">导出数据</a>
					</caption>
					<thead>
						<tr>
							<th>使用时间</th>
							<th>店铺名称</th>
							<th>优惠劵号</th>
							<th>会员卡号</th>
							<th>客户姓名</th>
							<th>手机</th>
							<th>数量</th>
							<th>面值</th>
							<th>状态</th>
							<th>备注</th>
							<th>打印</th>
						</tr>
					</thead>
					<tbody id="consumeList"></tbody>
				</table>
				<div id="NoResult"  class="Nothing" style="text-align:center;display: none;">
					无符合条件的数据！
				</div>
				<div id="sum" style="float: left;"></div>
				<div id="pager" style="float: right;"></div>
			</div>
			<div class="fc"></div>
		</div>
		<!-- InstanceEndEditable -->
		<script type="text/javascript" src="../js/header.js"></script>
		<script type="text/javascript" src="../js/left.js"></script>
		<script type="text/javascript" src="../js/footer.js"></script>
		<script type="text/javascript">
			clearThis("absoluteTxt");
			showTab(4, 4);
		</script>
	</body>
	<!-- InstanceEnd -->
</html>
